package models

import (
	"go-web/dao"
	"time"
)

type User struct {
	ID          uint      `json:"id"`
	Name        string    `json:"name"`
	Email       string    `json:"email"`
	Age         uint8     `json:"age,omitempty"`
	Birthday    time.Time `json:"birthday,omitempty"`
	MemberNum   string    `json:"member_number,omitempty"`
	ActivatedAt time.Time `json:"activated_at,omitempty"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

func (User) TableName() string {
	return "users"
}

func GetUser(id int) (User, error) {
	var user User
	err := dao.Db.Where("id = ?", id).First(&user).Error
	return user, err
}
